package com.lyj.service.impl;

import java.util.List;

import com.lyj.dao.RecordDao;
import com.lyj.dao.impl.RecordDaoImpl;
import com.lyj.pojo.Record;
import com.lyj.pojo.RecordQueryModel;
import com.lyj.service.RecordService;
import com.lyj.util.RuleException;

/**
* 
* @author 李艺江
* @version 创建时间：2018年12月18日 下午6:53:30
*/

public class RecordServiceImpl implements RecordService{

	private RecordDao recordDao;
	
	public RecordServiceImpl() {
		this.recordDao = new RecordDaoImpl();
	}
	
	@Override
	public void insert(Record record) throws Exception {

		if(record.getOptionId() == null) {
			throw new RuleException("请勾选!");
		}
		recordDao.insert(record);
		
	}


	@Override
	public List<Record> getRecordsBySubjectId(Long subjectId) throws Exception {
		RecordQueryModel qm = new RecordQueryModel();
		qm.setSubjectId(subjectId);
		List<Record> records = recordDao.findByCondition(qm);
		return records;
	}

	@Override
	public List<Record> getRecordsByOptiontId(Long optionId) throws Exception {
		RecordQueryModel qm = new RecordQueryModel();
		qm.setOptionId(optionId);
		List<Record> records = recordDao.findByCondition(qm);
		return records;
	}

}
